<?php


namespace app\home\controller;

use app\common\model\Table;
use app\home\ApiBaseController;

//不需要验证
use app\home\service\CardSettlementService;
use app\home\service\OpenPaiCalculationService;
use app\home\service\TransferBetService;
use app\home\UserBaseController;

//需要验证

class Base extends UserBaseController
{
    public static $user;

    public function initialize()
    {

       // $this->test_puke();
        parent::initialize(); // TODO: Change the autogenerated stub
        $this->get_user_info();
    }

    public function get_user_info(): string
    {
        self::$user = session('home_user');
        if (self::$user) {
            self::$user['head_img'] = config('ToConfig.app_update.image_url') . '/' . self::$user['head_img'];
            return '';
        }
        return show([], config('ToConfig.http_code.error'), '请登录');
    }

    //测试扑克开牌 在上面调用该方法，写入值
    public function test_puke()
    {



        die;

        $data = [
            "status" => 1,
            "table_id" => "5",
            "xue_number" => "1",
            "pu_number" => "1",
            "game_type" => "3",
            "result" => "1|0",
            "result_pai" => '{"1":"1|0","2":"2|m","3":"3|h","4":"2|m","5":"1|r","6":"0|0"}',
            "create_time" => 1632359315,
            "update_time" => 1632359315,
            "luzhu_id" => "2",
        ];
        $card_service = new CardSettlementService();
        $luzhu_id = $data['luzhu_id'];
        unset($data['luzhu_id']);
        $res = $card_service->user_settlement($luzhu_id,$data);
        dump($res);die;
//        $q = new TransferBetService();
//        $w = $q->user_agent_money_settle();
//
//        die;
//        $a = new CardSettlementService();
//
//
//        $post['result_pai'] = '{"1":"0|0","2":"1|m","3":"3|h","4":"2|m","5":"1|r","6":"0|0"}';
//        $post['result'] = '1|0';
//        $post['xue_number'] = 1;
//
//        $post['status'] = 1;
//        $post['table_id'] = 4;
//        $post['xue_number'] = 1;
//        $post['pu_number'] = 3;
//        $post['game_type'] = 3;
//
//
//        $a = $a->user_settlement(700, $post);
//
//        dump($a);
//        die;
//
//
//        $a = new OpenPaiCalculationService();
//        $pai = '{"1":"0|0","2":"3|m","3":"3|h","4":"2|m","5":"1|r","6":"0|0"}';
//        $pai_result = $a->runs(json_decode($pai, true));
//        dump($pai_result);
//        die;
        $c = new CardSettlementService();
        $d = $c->get_pai_info(1, 3);
        dump($d);
        die;
    }
}